﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;

namespace GrayParrot.Web.Controls
{
    /// <summary>
    /// Controller Configuration class...
    /// </summary>
    /// <remarks>
    /// Set the configuration controller class specifying the url for load data and the eventually parameters...
    /// </remarks>
    public class ControllerConfig
    {
        /// <summary>
        /// Gets or sets the URL of the loading server function...
        /// </summary>
        /// <value>
        /// The URL...
        /// </value>
        /// <remarks>
        /// the url can be:
        /// a Web Method of server side page:  WebForm1.aspx/LoadMethod
        /// an Http Handler:                   Handler1.ashx
        /// </remarks>
        public string Url { get; set; }

        /// <summary>
        /// Gets or sets the loading mode...
        /// </summary>
        /// <value>
        /// Define the loading mode for the grid data...
        /// </value>
        /// <remarks>
        /// The are two loading modes:
        /// OnLoad: the data are loaded on page load (default).
        /// OnDemand: the data are loaded on Custom Button Click.
        /// </remarks>
        [DefaultValue(LoadingModes.OnLoad)]
        public LoadingModes LoadingMode { get; set; }

        /// <summary>
        /// Gets or sets the controller parameters...
        /// </summary>
        /// <value>
        /// Controller parameters collection...
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)]
        public List<ControllerParameter> ControllerParameters { get; set; }

        /// <summary>
        /// Gets or sets the controller parameters validation configuration...
        /// </summary>
        /// <value>
        /// The validation configuration.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)]
        public ValidationConfig Validation { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="ControllerConfig"/> class.
        /// </summary>
        public ControllerConfig()
        {
            this.LoadingMode = LoadingModes.OnLoad;
            this.ControllerParameters = new List<ControllerParameter>();
        }
    }
}
